package com.chen.demo.rhombus.ohs.remote.controller;

import com.chen.demo.rhombus.domain.vo.UserVo;
import com.chen.demo.rhombus.ohs.local.appservice.UserAppService;
import com.chen.demo.rhombus.ohs.local.pl.command.UserAddCommand;
import com.chen.demo.rhombus.ohs.local.pl.command.query.UserPageQuery;
import com.chen.winnerframework.http.request.Request;
import com.chen.winnerframework.http.response.PageResponse;
import com.chen.winnerframework.http.response.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequiredArgsConstructor
@RequestMapping("/rhombus/user")
public class UserController {

    private final UserAppService userAppService;

    @PostMapping("/add")
    public Response add(@Valid @RequestBody Request<UserAddCommand> request) {
        return userAppService.addUser(request.getParams());
    }

    @PostMapping("/page")
    public PageResponse<UserVo> page(@Valid @RequestBody Request<UserPageQuery> request) {
        return userAppService.pageQueryUser(request.getParams());
    }
}
